package com.bop.dehong.util;

import com.bop.dehong.R;
import com.bop.dehong.widget.dialog.Effectstype;
import com.bop.dehong.widget.dialog.NiftyDialogBuilder;

import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;

public class CommonDialog {
	private Context mContext;
	private OnLeftClickListener leftClickListener;
	public interface OnLeftClickListener{
		void setOnClickLeftResult();
	}
	
	public void setOnLeftClickListener(OnLeftClickListener leftClickListener){
		this.leftClickListener=leftClickListener;
	};

	public CommonDialog(Context context){
		this.mContext=context;
	}
	
	public void showDialog(String Content){
	 final NiftyDialogBuilder builder = NiftyDialogBuilder.getInstance(mContext);
		builder.withMessage(Content);
		builder.withButtonLeftText(mContext.getString(R.string.sure));
		builder.withButtonRightText(mContext.getString(R.string.cancel));
		builder.withEffect(Effectstype.RotateBottom);
		builder.withDuration(300);
		builder.isCancelable(false);
		builder.isCancelableOnTouchOutside(false);
		builder.setButtonLeftClick(new OnClickListener() {
			@Override
			public void onClick(View v) {
				builder.dismiss();
				 if(leftClickListener!=null){
					 leftClickListener.setOnClickLeftResult();
				 }
			}
		});
		builder.setButtonRightClick(new OnClickListener() {
			@Override
			public void onClick(View v) {
				builder.dismiss();
			}
		});
		builder.show();
	}
}
